/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package TextoAgregar;

import java.awt.Button;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Panel;
import java.awt.TextArea;
import java.awt.TextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

/**
 *
 * @author Lab
 */
public class Agregar {
/*
   class ventana{
       ventana v=new ventana();
   }*/

private TextField t=new TextField(30);

private TextArea a=new TextArea();
private Button b=new Button("agregar");
  private Button b1=new Button("reset");

public void ventana(){
    Frame f = new Frame();

    FlowLayout flo = new FlowLayout();//acomoda distancia uno en otro de izquierda a derecha

 Panel p= new Panel();
 Panel p1= new Panel();
 Panel p2= new Panel();
        f.addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
     f.setLayout(new GridLayout(1, 0));///pone columna y filas

  //  f.add(BorderLayout.SOUTH,t);
   // f.add(BorderLayout.CENTER,a);

b.addActionListener(new manejoboton ());
   
    f.add(p);
    f.add(p1);
    f.add(p2);

    p.add(t);
    p.add(a);
    p1.add(b);
    p1.add(b1);

f.setVisible(true);
    f.setSize(500, 500);


}
class  manejoboton implements ActionListener{
        public void actionPerformed (ActionEvent e){
            a.append("\n"+t.getText());
        }
    }
class teclado extends KeyAdapter{
    public void keyPressed (KeyEvent e){
        if(e.getKeyCode()==10)
            a.append("\n"+t.getText());
    }

}
class Cambiarcolor extends MouseAdapter{
    public void mouseEntered(MouseEvent e){
        b.setBackground(Color.GREEN);
    }
public void mouseExited(MouseEvent e){
    b.setBackground(Color.RED);
}
}


  public static void main(String[] args) {
        // TODO code application logic here
   Agregar v=new Agregar();

      v.ventana();
    }


}
